package entity;
import java.util.Date;
//import Controller.DBcontroller;

import client.DBcontroller;

public class Prices {
private enum validateErrs{OCCERR,ORDERR,PNUMERR}; // this is an enum for setting errors for the validate function.

private double OccasionalParkingPlace; // this is the only price (per hours) that we can change.
private double OrderedParkingPlace; // this is also the only price (per hours) that we can change.
private double MonthlyRegularSubscriber; // the formula for this is: 60*OrderedParkingPlace.
private double RegularSubscriberForManyCars; // the formula for this is: 0.9*(MonthlyRegularSubscriber*numofcars).  
private double FullMonthlySubscriber; // the formula for this is: 72*OrderedParkingPlace.
private int parkingLotNumber; // this is the parking lot number of the changing prices.
private Date dateOfSubmission; // this is the date of submission, which is relevant only for the parking lot manager.

// This will be the new default constructor for the prices object.
public Prices(int parknum)
{
	this.dateOfSubmission=new Date(); // set the date to today's date.
	this.OccasionalParkingPlace=5; // set this price to his default.
	this.OrderedParkingPlace=4; // set this price to his default.
	this.MonthlyRegularSubscriber=60*this.OrderedParkingPlace; // calculate the price according to the formula.
	this.FullMonthlySubscriber=72*this.OrderedParkingPlace; // calculate the price according to the formula.
	this.parkingLotNumber=parknum; // saving the parking place number. 
	this.RegularSubscriberForManyCars=this.MonthlyRegularSubscriber*0.9;
}

// the get functions.
public Date getDateOfSubmission() {return dateOfSubmission;}
public double getFullMonthlySubscriber() {return FullMonthlySubscriber;}
public double getMonthlyRegularSubscriber() {return MonthlyRegularSubscriber;}
public double getOccasionalParkingPlace() {return OccasionalParkingPlace;}
public double getOrderedParkingPlace() {return OrderedParkingPlace;}
public int getParkingLotNumber() {return parkingLotNumber;}

// the set functions.
public void setOccasionalParkingPlace(double occasionalParkingPlace) {OccasionalParkingPlace = occasionalParkingPlace;}
public void setOrderedParkingPlace(double orderedParkingPlace) {OrderedParkingPlace = orderedParkingPlace;}
public void setParkingLotNumber(int parkingLotNumber) {parkingLotNumber = parkingLotNumber;}

// This function is for validating the vars.
public validateErrs validate()
{
	if(this.OccasionalParkingPlace<=0)
		return validateErrs.OCCERR;
	if(this.OrderedParkingPlace<=0)
		return validateErrs.ORDERR;
	if(this.parkingLotNumber<=0||this.parkingLotNumber>6)
		return validateErrs.PNUMERR;
	return null;
}

// this function is for saving complaint to the DB.
public void save()
{
	Prices p=new Prices(this.parkingLotNumber);
	DBcontroller db=new DBcontroller(); 
	db.savePricesToDB(p);
}

}